package icu.qx.diagram.service.impl;

import icu.qx.diagram.domain.Drawback;
import icu.qx.diagram.mapper.DrawbackMapper;
import icu.qx.diagram.service.IDrawbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrawbackServiceImpl implements IDrawbackService {
    @Autowired
    private DrawbackMapper drawbackMapper;

    /**
     * 缺陷统计
     * @param drawback
     * @return
     */
    @Override
    public List<Drawback> selectDrawbackList(Drawback drawback) {
        List<Drawback> drawbackList=drawbackMapper.selectDrawbackList(drawback);
        for(Drawback d:drawbackList){
            if(d.getReportGood()==null||d.getReportCompleteNum()==null){
                d.setReportBad(0);
            }else{
                d.setReportBad(d.getReportCompleteNum()-d.getReportGood());
            }
        }
        return drawbackList;
    }
}
